package alone.sub.table.test.demo.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;


@ControllerAdvice
public class GlobalExceptionHandler {


    @ExceptionHandler({DatabaseException.class})
    @ResponseBody
    public Object handleDatabaseException(HttpServletRequest request,DatabaseException e){
        Map<String,String> map = new HashMap<>();
        map.put(request.getRequestURL().toString(),e.getMessage());
        return map;
    }


}
